package com.bit.forum.controller;

import com.bit.forum.exception.ApplicationException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {

    @GetMapping("/hello")
    public String hello(){
        return "hello spring boot";
    }

    @GetMapping("/helloByName")
    public String helloByName(@RequestParam("name") String name){
        return "hello " + name;
    }

    @GetMapping("/appException")
    public String testApplicationException(){
        throw new ApplicationException("这是⼀个⾃定义的ApplicationException");
    }

    @GetMapping("/exception")
    public String testException() throws Exception{
        throw new Exception("这是⼀个Exception");
    }
}
